<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            /* 给父元素添加flex属性 */
            display: flex;
            width: 600px;
            background-color: aquamarine;
            /* flex布局中，默认的子元素是不换行的，如果撞不开，则会缩小子元素的宽度 ，默认放到父元素里面*/
            /* flex-wrap: nowrap;默认 */
            /* 装不下则换行 */
            flex-wrap: wrap;
            }

        span{
           width: 150px;
           height: 100px;
           background-color: purple; 
           margin: 10px;
      }
    </style>
</head>

<body>
    <div>
        <span>1</span>
        <span>2</span>
        <span>3</span>
        <span>4</span>
    </div>
</body>

</html>